package leetcode;

/**
 * 描述:700. 二叉搜索树中的搜索
 *
 * @author Madison You
 * @created 11:15
 */
public class Easy_700_SearchBST {
    public static void main(String[] args) {
        TreeNode treeNode = CreateTreeNode.arrayToTreeNode(new Integer[]{4, 2, 7, 1, 3});
        TreeNode treeNode1 = new Easy_700_SearchBST().searchBST(treeNode, 2);
        System.out.println(treeNode1);
    }

    public TreeNode searchBST(TreeNode root, int val) {
        if (root == null || root.val == val) return root;
        return root.val > val ? searchBST(root.left, val) : searchBST(root.right, val);
    }
}
